<template>
  <div class="reds-modal login-modal" role="presentation">
    
  </div>
</template>

<script setup>
import { Close } from "@element-plus/icons-vue";
import { ElMessage } from 'element-plus'
import { loginOrRegister } from "@/api/index"
import { storage } from "@/utils/storage"
import { ref, reactive, onMounted, onUnmounted } from "vue";

const phone = ref('')
const areaCode = ref('+86')
const country = ref('China')
const code = ref('')
const terminal = ref('WEB')

const emit = defineEmits(["clickChild", "loginStatus"]);

// 登录
const login = async () => {
  const params = {
    phone: phone.value,
    areaCode: areaCode.value,
    country: country.value,
    code: code.value,
    terminal: terminal.value, // WEB、pc、OTHER、ANDROID、IOS
  };
  let res = await loginOrRegister(params)
  if (res.code == 200) {

    storage.set('info', {token: res.data.token, phone: res.data.phonenumber, fimConnection: {...res.data.fimConnection}})
    ElMessage.success('登录成功')
    phone.value = ''
    code.value = ''
    emit("loginStatus", false);
  } else {
    emit("loginStatus", true);
  }
};

const close = () => {
  //传递给父组件
  emit("clickChild", false);
};

</script>

<style lang="less" scoped>
a {
  text-decoration: none;
  background-color: transparent;
}
.login-modal {
  z-index: 100010;
  flex-direction: column;
}

</style>
